import axios from "@/utils/request";
import store from "@/store/store";
import qs from "qs";

//签到
const getSign = () => {
  // const headers = {
  //     Authorization: ' Bearer ' + store.state.token,
  //     'Content-Type': 'application/json'
  //  }
  return axios.get("/user/fav", {});
};
//更新用户基本资料
const updateUserInfo = (data) => {
  return axios.post("/user/basic", {
    ...data,
  });
};
//确认修改用户名
const updateUsername = (data) => {
  return axios.get("/public/reset-email?" + qs.stringify(data));
};
//修改密码
const updateWord = (newword) => {
  return axios.post("/user/upword", {
    ...newword,
  });
};
//用户主页
const getHomeList = (uid) => axios.get("/public/getinfo?" + qs.stringify(uid));
//获取用户发帖
const postList = (uid) => {
  return axios.get("user/post?" + qs.stringify(uid));
};
//删除文章
const setdel = (tid) => {
  return axios.get("user/del", {
    params: {
      tid: tid,
    },
  });
};
//获取收藏
const getcollect = (uid) => {
  return axios.get("user/collect?" + qs.stringify(uid));
};
//获取用户中心
const getInfor = (uid) => {
  return axios.get("public/info?" + qs.stringify(uid));
};

//获取未读消息
const getMsg = (data) => {
  return axios.get("user/getmsg?" + qs.stringify(data));
};
//设置
const setMsg = (id) => {
  return axios.get("user/setmsg?" + qs.stringify(id));
};
export {
  getSign,
  updateUserInfo,
  updateUsername,
  updateWord,
  postList,
  setdel,
  getcollect,
  getInfor,
  getMsg,
  setMsg,
  getHomeList,
};
